<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use App\Model\AdminSocre;
use Illuminate\Support\Facades\Redis;

class AdminSocres extends Controller
{
    //显示积分规则页面
    public function SocresList()
    {
        //返回积分页面视图
    	return view('Admin.socres.socres-list');
    }


    //将积分规则存入redis中
    public function SetSocres(Request $request)
    {
        //验证数据是否合法
        $this->validate($request, [
            'shop-score-rule' => 'required|numeric|max:0.10|min:0',
        ],[
            'shop-score-rule.required' => '积分规则不能为空', 
            'shop-score-rule.numeric' => '必须填写数字',
            'shop-score-rule.max' => '取值范围 0 - 0.10之间',
            'shop-score-rule.min' => '取值范围 0 - 0.10之间',      
        ]);

        // 存入redis
    	Redis::set('shop-score-rule', 0.01);

        // 返回保存后提示信息
        return back()->with('message', '保存成功');
    }

}
